
let oform=document.forms[0]


let btn=oform.login

oform.password.addEventListener('blur',function(){
    btn.style.opacity='1'
  
})


oform.addEventListener('submit',function(e){
    var e=e||window.Event
    let username=oform.username.value
    let password=oform.password.value

    if(username!=''&&password!=''){
        axios.post('http://api.yuguoxy.com/api/member/login', {
            username: username,
            password: password
          })
          //resultCode: -1, resultInfo:
          .then(function (response) {
            console.log(response.data);
            let data=response.data
            if(data.resultCode==1){
                console.log(data.resultCode);
                localStorage.setItem('login',JSON.stringify(data.resultInfo))
                alert('登陆成功')
                location.href='../pages/index.html'
            }
            if(data.resultCode==-1){
                alert(data.resultInfo)
            }
          })
          .catch(function (error) {
           console.log(error);
          
          });
    }else{
        alert('不能为空')
    }


    e.preventDefault()
})